package com.jinmdz.fmis.mapper.mapper;

import com.jinmdz.fmis.mapper.entity.BusinessSystemEntity;
import com.jinmdz.fmis.mapper.mapper.provider.BusinessSystemProvider;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

/**
 * 业务子系统Mapper
 *
 * @author generator
 * @date 2020-03-18 08:58
 */
public interface BusinessSystemMapper {

    /**
     * 增加BusinessSystem
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-18 08:58
     */
    @InsertProvider(type = BusinessSystemProvider.class, method = "insertBusinessSystem")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertBusinessSystem(@Param("entity") BusinessSystemEntity entity);

    /**
     * 删除BusinessSystem
     *
     * @param id             主键
     * @param modifiedUserId 修改用户外键
     * @param version        版本号
     * @return
     * @author generator
     * @date 2020-03-18 08:58
     */
    @Update(" update business_system set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForBusinessSystem(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改BusinessSystem
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-18 08:58
     */
    @UpdateProvider(type = BusinessSystemProvider.class, method = "updateBusinessSystem")
    void updateBusinessSystem(@Param("entity") BusinessSystemEntity entity);

    /**
     * 查询BusinessSystem实体
     *
     * @param id 主键
     * @return BusinessSystemEntity
     * @author generator
     * @date 2020-03-18 08:58
     */
    @Select(" select id,deleted,system_name,system_code,disable_state,sort,remark,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from business_system where id = #{id} and deleted = 0 limit 1 ")
    BusinessSystemEntity getBusinessSystemById(@Param("id") Integer id);

    /**
     * 查询BusinessSystem列表
     *
     * @param entity 数据实体
     * @return BusinessSystemEntity
     * @author generator
     * @date 2020-03-18 08:58
     */
    @SelectProvider(type = BusinessSystemProvider.class, method = "listBusinessSystem")
    ArrayList<BusinessSystemEntity> listBusinessSystem(@Param("entity") BusinessSystemEntity entity);
}